Skip to content

fix: handle setting protected/type-enforced attributes correctly #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 2, 2025

Conversation

cwaldren-ld
Copy link
Contributor

@cwaldren-ld cwaldren-ld commented Aug 15, 2024

This addresses a bug where you couldn't set the name attribute as private using the AttributesBuilder::SetPrivate(key, value) API.

The issue was that this API forwards to an internal AttributesBuilder::Set(key, value, is_private) method, which disallowed setting of "protected" attributes.

In this PR, I've re-designated attributes as:

  1. "protected": they cannot be set using the Set APIs at all
    • This includes _meta, kind, and key.
  2. "typed": they can be set using Set, but must have the correct type
    • This includes anonymous and name
  3. All other attributes, which don't have any type checking

Within (2), the current behavior is that both of these can be marked private, which isn't really correct. In reality only name can be redacted.

So currently, you could say SetPrivate("anonymous, true), and it'd set it and add it to the private attributes list. Come redaction time, it wouldn't be redacted.

To make this totally consistent, we'd need to disallow SetPrivate("anonymous", ..) as well as modify the AddPrivateAttribute and AddPrivateAttributes APIs.

Perhaps the behavior in this PR is sufficient, given some documentation that mentions that setting anonymous private isn't meaningful.

@cwaldren-ld cwaldren-ld changed the title fix: handle protected attributes correctly fix: handle protected/type-enforced attributes correctly Aug 15, 2024
@cwaldren-ld cwaldren-ld changed the title fix: handle protected/type-enforced attributes correctly fix: handle setting protected/type-enforced attributes correctly Aug 15, 2024
@cwaldren-ld cwaldren-ld marked this pull request as ready for review August 16, 2024 18:07
@cwaldren-ld cwaldren-ld requested a review from a team as a code owner August 16, 2024 18:07
@cwaldren-ld cwaldren-ld requested a review from kinyoklion August 16, 2024 18:07
@keelerm84 keelerm84 requested a review from kinyoklion April 29, 2025 14:37
@keelerm84 keelerm84 merged commit d73de43 into main May 2, 2025
9 checks passed
@keelerm84 keelerm84 deleted the cw/sc-228274/protected-attributes branch May 2, 2025 17:18
@github-actions github-actions bot mentioned this pull request May 2, 2025
keelerm84 pushed a commit that referenced this pull request May 2, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>launchdarkly-cpp-client: 3.9.0</summary>

##
[3.9.0](launchdarkly-cpp-client-v3.8.2...launchdarkly-cpp-client-v3.9.0)
(2025-05-02)


### Features

* generate events for flag prerequisites
([#465](#465))
([30378a1](30378a1))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-internal bumped from 0.10.1 to 0.11.0
    * launchdarkly-cpp-common bumped from 1.9.0 to 1.10.0
</details>

<details><summary>launchdarkly-cpp-common: 1.10.0</summary>

##
[1.10.0](launchdarkly-cpp-common-v1.9.0...launchdarkly-cpp-common-v1.10.0)
(2025-05-02)


### Features

* generate events for flag prerequisites
([#465](#465))
([30378a1](30378a1))


### Bug Fixes

* handle setting protected/type-enforced attributes correctly
([#433](#433))
([d73de43](d73de43))
</details>

<details><summary>launchdarkly-cpp-internal: 0.11.0</summary>

##
[0.11.0](launchdarkly-cpp-internal-v0.10.1...launchdarkly-cpp-internal-v0.11.0)
(2025-05-02)


### Features

* generate events for flag prerequisites
([#465](#465))
([30378a1](30378a1))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-common bumped from 1.9.0 to 1.10.0
</details>

<details><summary>launchdarkly-cpp-server: 3.8.2</summary>

##
[3.8.2](launchdarkly-cpp-server-v3.8.1...launchdarkly-cpp-server-v3.8.2)
(2025-05-02)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-internal bumped from 0.10.1 to 0.11.0
    * launchdarkly-cpp-common bumped from 1.9.0 to 1.10.0
</details>

<details><summary>launchdarkly-cpp-server-redis-source: 2.1.18</summary>

##
[2.1.18](launchdarkly-cpp-server-redis-source-v2.1.17...launchdarkly-cpp-server-redis-source-v2.1.18)
(2025-05-02)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-server bumped from 3.8.1 to 3.8.2
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants